package com.wantong.jianpu.models;

import com.trello.rxlifecycle2.LifecycleProvider;
import com.wantong.jianpu.beans.MessageBean;
import com.wantong.jianpu.beans.UpLoadBean;
import com.wantong.jianpu.beans.UserBean;
import com.wantong.jianpu.net.BaseObserver;
import com.wantong.jianpu.net.HttpUtils;
import com.wantong.jianpu.net.RetrofitUtil;

import java.util.Map;

import io.reactivex.Observable;
import me.goldze.mvvmhabit.base.BaseModel;

/**
 * @author PACY
 * @date 2022/6/3
 * description:
 */
public class OtherModel extends BaseModel {

    /**
     * 获取用户信息
     *
     * @param observer
     * @param lifecycle
     */
    public void getUserInfo(BaseObserver<UserBean> observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().getUserInfo();
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     * 修改密码
     *
     * @param observer
     * @param lifecycle
     */
    public void resetPwd(Map<String,Object> map , BaseObserver<UserBean> observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().resetPwd(HttpUtils.buildBody(map));
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     * 查询消息列表
     *
     * @param observer
     * @param lifecycle
     */
    public void messageList(Map<String,Object> map , BaseObserver<MessageBean> observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().messageList(map);
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     * 设置消息已读
     *
     * @param observer
     * @param lifecycle
     */
    public void receive(Map<String,Object> map , BaseObserver observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().receive(HttpUtils.buildBody(map));
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     * 获取未读消息
     *
     * @param observer
     * @param lifecycle
     */
    public void getMessage(BaseObserver observer, LifecycleProvider<Integer> lifecycle) {
        Observable observable = RetrofitUtil.getApiService().getMessage();
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }
}
